package cn.base.demo3;

public class Code12 {
    public static void main(String[] args) {
        // - 定义一个方法, 参数是一个double类型数组,里面是用来存储学生分数.
        // - 方法可以统计数组中所有所有超过平均分的分数的数量,并且返回.
        double[] arr1 = {10.2, 15.3, 13.2};
        System.out.println(getAver(arr1));

    }

    public static int getAver(double[] arr) {
        int count = 0;
        double sum = 0;
        for (int i = 0; i < arr.length; i++) {
            sum += arr[i];
        }
        double arv = sum / arr.length;
        System.out.println(arv);
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] > arv) {
                count++;
            }
        }
        return count;
    }
    public static double getAver(int[] arr) {
        int count = 0;
        double sum = 0;
        for (int i = 0; i < arr.length; i++) {
            sum += arr[i];
        }
        double arv = sum / arr.length;
        System.out.println(arv);
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] > arv) {
                count++;
            }
        }
        return count;
    }
}
